import { ProFormDigit, ProFormGroup, ProFormSelect, ProFormText } from '@ant-design/pro-form';
import { TenantEntityFormat } from '../Tenant/entities';

export const formChildren = (tenant: TenantEntityFormat) => {

  return (
    <>
      <ProFormText
        name='name'
        label='名称'
        rules={[
          { required: true, message: '请填写名称' },
        ]}
      />
      <ProFormSelect
        name='allow_nodes'
        label='节点'
        rules={[
          { required: true, message: '请选择节点' },
        ]}
        mode={'multiple'}
        options={tenant.allow_nodes.map((node) => ({ label: node, value: node }))}
      />
      <ProFormGroup>
        <ProFormDigit
          label={`最大CPU(核)(1 ~ ${tenant.max_cpu})`}
          name='max_cpu'
          width='sm'
          min={1}
          max={tenant.max_cpu}
          dataFormat='string'
          rules={[
            { required: true, message: '请填入最大CPU' },
          ]}
        />

        <ProFormDigit
          label={`最大内存(G)(1 ~ ${tenant.max_memory})`}
          name='max_memory'
          width='sm' min={1}
          max={tenant.max_memory}
          rules={[
            { required: true, message: '请填入最大内存' },
          ]}
        />

        <ProFormDigit
          label={`最大硬盘(G)(1 ~ ${tenant.max_disk})`}
          name='max_disk'
          width='sm'
          min={1}
          max={tenant.max_disk}
          rules={[
            { required: true, message: '请填入最大硬盘' },
          ]}
        />
      </ProFormGroup>
    </>
  );
};
